// 总结一些ajax 的重复的地方，封装掉

/**
 *
 * @param data:<object(url, body)>
 *
*/

import {
    ajax,
    toast
} from 'nc-lightapp-front';


export default (data) => {

    return new Promise((resolve, reject) => {
        ajax({
            url: data.url,
            method: 'post',
            data: data.body,
            success: (res) => {
                resolve(res);
            },
            error: (err) => {
                toast({
                    color: 'danger',
                    // content: `<div style='max-width:430px;word-break: break-word;white-space: normal;'>${err.message}</div>`
                    content: err.message
                });
                reject(err);
            }
        });

    });
}
